home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
basic
/
qbnws204.zip
/
WINDOWS.ZIP
/
DISPLAY.ASM
next >
Wrap
Assembly Source File
|
1991-07-15
|
32KB
|
599 lines
; DISPLAY.ASM ─ contains a collection of video-related procedures and
; functions for use with Microsoft high-level languages.
;
; Author: Christy Gemmell
; For: Assembly-Language Toolbox for QuickBASIC
; Version: 5.0
; Date: 9/6/1991
;
; Compatible with Microsoft QuickBASIC 4.x and BASIC 6 compilers.
; Assembled using Microsoft Macro Assembler, MASM version 5.1
;
;┌────────────────────────────────────────────────────────────────────────┐
;│ Global symbols and procedures. │
;└────────────────────────────────────────────────────────────────────────┘
;
.model medium
public ScreenAddress
public ScreenCopy
public ScreenRead
public ScreenWrite
public VideoType
public WriteByte
public Attribute
public Delay
public Explode
public FastPrint
.code
;┌────────────────────────────────────────────────────────────────────────┐
;│ Data Division. │
;└────────────────────────────────────────────────────────────────────────┘
;
; Video parameters - default to monochrome screen display
;
SnowFlag db 0 ; Snow prevention flag
VideoRam dw 0B000h ; Current video segment
VideoPort dw 03BAh ; Current video status port
Param1 label word
Mode db 7 ; Current screen mode
Columns db 80 ; Current screen width
Param2 label word
Rows db 25 ; Current screen length
ActivePage db 0 ; Current video page
TopLeft label word ; Upper left co-ordinates
H1 db ? ; Horizontal length
V1 db ? ; Vertical height
BotRight label word ; Lower right co-ordinates
H2 db ? ; Horizontal length
V2 db ? ; Vertical height
Factor label word
dw 0
dw 0
Counter label word
dw ?
dw ?
Seed label word
dw 7397
dw 29447
dw 802
Multiple label word
dw 179
dw 183
dw 182
Modulus label word
dw 32771
dw 32779
dw 32783
;┌────────────────────────────────────────────────────────────────────────┐
;│ Calculate address from a pair of row/column co-ordinates. │
;└────────────────────────────────────────────────────────────────────────┘
;
; Given the row/column column co-ordinate of a character on the screen,
; this function returns the segment:offset address of that character in
; video memory. The address is correctly adjusted to the start of the
; the currently active display page, but no check is made to ensure that
; the co-ordinates supplied are within the actual screen bounds.
;
; Input: AL = Row co-ordinate of character (base zero).
; AH = Column co-ordinate of character (base zero).
;
; Output: ES:DI==> Address in video display buffer of the
; character cell specified.
; DX = CRT status register port address.
;
; It is assumed that a previous call has been made to the VideoType
; function, above, to determine the screen width, the port address of
; the CRT status register and the correct video display segment.
;
ScreenAddress proc far
push ax ; Save working registers
push bx
mov bh,ah ; Column to BH
mov bl,cs:Columns ; Get current screen width
shl bl,1 ; Add in attribute bytes
mul bl ; Multiply by row number
xor bl,bl ; Calculate
xchg bh,bl ; column offset
shl bl,1 ; in BX
add ax,bx ; Add it to the row offset
mov di,ax ; and copy to DI
xor ax,ax ; Index to ROM-BIOS
mov es,ax ; data in low memory
mov ax,es:[44Eh] ; Get offset of current page
add di,ax ; Adjust target pointer
mov es,cs:VideoRam ; Return segment of video RAM
mov dx,cs:VideoPort ; Return CRT status port
pop bx ; Clean up the stack
pop ax
ret ; and return to caller
ScreenAddress endp
;┌────────────────────────────────────────────────────────────────────────┐
;│ Copy a character and attribute from the video display. │
;└────────────────────────────────────────────────────────────────────────┘
;
; If the 'snow prevention' flag is set, this routine waits until the
; beginning of the next CRT horizontal retrace period before reading
; data from the display. This is necessary only on machines fitted with
; a Colour Graphics Adaptor (CGA) which may suffer from glitches or
; screen snow if data is copied from the screen while the video buffer
; is being refreshed.
;
; Input: DS:SI==> Address of the screen location from which
; the data is to be copied.
; ES:DI==> Address of the buffer into which the data
; is to be copied.
; DX = Port address of CRT status register.
;
; Output: SI and DI Updated to point to next buffer locations.
; AX destroyed.
;
ScreenCopy proc far
cmp cs:SnowFlag,0 ; Snow prevention needed?
cli ; Don't interrupt!
jz Copy_03 ; No, don't bother
Copy_01:
in al,dx ; Read video port
test al,1 ; Test bit zero
jnz Copy_01 ; Wait until it's reset
Copy_02:
in al,dx ; Read port again
test al,1 ; Test bit zero
jz Copy_02 ; Wait until it's set
Copy_03:
movsw ; Transfer one word
sti ; Restore interrupts
ret
ScreenCopy endp
;┌────────────────────────────────────────────────────────────────────────┐
;│ Read a character and attribute from the display. │
;└────────────────────────────────────────────────────────────────────────┘
;
; This procedure is similar to ScreenCopy, above, except that the word
; is simply loaded into AX instead of being copied into a buffer.
;
; Input: DS:SI==> address, in the video display buffer, from
; where the data is to be read
; DX = port address of the CRT status register.
;
; Output: AL = character at the specified address
; AH = display attribute given to character
; DI updated to point to the next word address
;
ScreenRead proc far